//操作成功之后提示
function success(text){
	  $("#alerts").html("<div  style='text-align: center; display:no;' class='alert alert-success alert-dismissable'><strong>"+text+"</strong></div>");
	  $("#menus").click();

}
function myfresh(){
	window.location.href=window.location.href;
}
//停用顾客或经销商子账号
function toUpdatecustomer(customerId){
	$.post(
			"../member/toUpdatecustomer.do?customerId="+customerId,
			function(data){
				if(data==1){
					success("停用成功!");
					setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,停用未成功!原因:数据库异常或者你没有修改数据!!");
				}
			}
	);
}
//根据注册时间降序排序经销商
function jiangxuDealer(currentPage){
	window.location.href="../member/dealerJ.do?currentPage="+currentPage;
}
//根据注册时间升序排序经销商
function shengxuDealer(currentPage){
	window.location.href="../member/dealerS.do?currentPage="+currentPage;
}
//正常经销商
function zhengchangDealer(currentPage){
	window.location.href="../member/dealer.do?currentPage="+currentPage;
}
//根据注册时间降序排序
function jiangxu(currentPage){
	window.location.href="../member/customerJ.do?currentPage="+currentPage;
}
//根据注册时间升序排序
function shengxu(currentPage){
	window.location.href="../member/customerS.do?currentPage="+currentPage;
}
//正常
function zhengchang(currentPage){
	window.location.href="../member/customer.do?currentPage="+currentPage;
}
//搜索顾客
function searchCustomer(currentPage){
	var search = $("#search").val();
	location.href="searchCustomer.do?search="+search+"&currentPage="+currentPage;
}
//搜索经销商
function searchDealer(currentPage){
	var search = $("#search").val();
	location.href="searchDealer.do?search="+search+"&currentPage="+currentPage;
}
//停用经销商
function toUpdatedealer(dealerId){
	$.post(
			"../member/toUpdatedealer.do?dealerId="+dealerId,
			function(data){
				if(data==1){
					success("停用成功!");
					setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,停用未成功!原因:数据库异常或者你没有修改数据!!");
				}
			}
	);
}
//根据注册时间降序排序工人
function jiangxuWorker(currentPage){
	window.location.href="../member/workerJ.do?currentPage="+currentPage;
}
//根据注册时间升序排序工人
function shengxuWorker(currentPage){
	window.location.href="../member/workerS.do?currentPage="+currentPage;
}
//正常工人
function zhengchangWorker(currentPage){
	window.location.href="../member/worker.do?currentPage="+currentPage;
}
//搜索经销商
function searchWorker(currentPage){
	var search = $("#search").val();
	location.href="searchWorker.do?search="+search+"&currentPage="+currentPage;
}
//停用工人
function toUpdateworker(workerId){
	$.post(
			"../member/toUpdateworker.do?workerId="+workerId,
			function(data){
				if(data==1){
					success("停用成功!");
					setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,停用未成功!原因:数据库异常或者你没有修改数据!!");
				}
			}
	);
}
//根据id查询供货商信息
function selectSupplier(supplierId){
	$.post(
			"../member/selectSupplier.do?supplierId="+supplierId,
			function(data){
				$("#shuxing1>div>input").val(data.supplierId);
				$("#shuxing2>div>input").val(data.name);
				$("#shuxing3>div>input").val(data.address);
			},
			'json'
	);
}
//保存供货商
function saveSupplier(){	
	$.post(
			"../member/saveSupplier.do",
			$("#supplierX").serialize(),
			function(data){
				if(data==1){
					success("恭喜您, 修改成功!");
					 setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,修改未成功!原因:数据库异常或者你没有修改数据!!");
					setTimeout(myfresh,1000);
				}
			}
	);
}
//删除供货商
function deleteSupplier(supplierId){	
	$.post(
			"../member/deleteSupplier.do?supplierId="+supplierId,
			function(data){
				if(data==1){
					success("删除成功!");
					 setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,删除未成功!原因:数据库异常或者你没有修改数据!!");
					setTimeout(myfresh,1000);
				}
			}
	);
}
//添加供货商
function insertSupplier(){	
	$.post(
			"../member/insertSupplier.do",
			$("#supplierT").serialize(),
			function(data){
				if(data==1){
					success("添加成功!");
					 setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,添加未成功!原因:数据库异常或者你没有修改数据!!");
					setTimeout(myfresh,1000);
				}
			}
	);
}
//搜索供货商
function searchSupplier(currentPage){
	var search = $("#search").val();
	location.href="searchSupplier.do?search="+search+"&currentPage="+currentPage;
}